package com.xy.biz.uc.domain.query;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class UserGroupIdQuery {

    /**
     * 分组Id集合
     */
    private List<Long> userGroupIdList;
    /**
     * 是否查询上级分组
     */
    private boolean withParent;
    /**
     * 是否查询角色
     */
    private boolean withRole;

    public UserGroupIdQuery addUserGroupId(Long userGroupId) {
        if(userGroupIdList == null) {
            userGroupIdList = new ArrayList<>();
        }
        userGroupIdList.add(userGroupId);
        return this;
    }

    public Long firstUserGroupId() {
        return CollectionUtils.isEmpty(userGroupIdList) ? null : userGroupIdList.get(0);
    }

}
